package com.anti.modular.owner.ownerleasebilldetail.controller;

import com.anti.commom.annotation.BusinessLog;
import com.anti.commom.annotation.Permission;
import com.anti.commom.enums.LogAnnotionOpTypeEnum;
import com.anti.commom.api.Result;
import com.anti.jdbc.support.page.PageParam;
import com.anti.modular.owner.ownerleasebilldetail.param.OwnerLeaseBillDetailParam;
import com.anti.modular.owner.ownerleasebilldetail.service.OwnerLeaseBillDetailService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 業主賬單明細控制器
 *
 * @author anti
 * @date 2021-05-20 14:26:44
 */
@RestController
@RequestMapping("ownerLeaseBillDetail")
public class OwnerLeaseBillDetailController {

    @Resource
    private OwnerLeaseBillDetailService ownerLeaseBillDetailService;

    /**
     * 查询業主賬單明細
     *
     * @author anti
     * @date 2021-05-20 14:26:44
     */
    @GetMapping("page")
    public Result page(PageParam pageParam, OwnerLeaseBillDetailParam ownerLeaseBillDetailParam) {
        return Result.data(ownerLeaseBillDetailService.page(pageParam,ownerLeaseBillDetailParam));
    }

    /**
     * 添加業主賬單明細
     *
     * @author anti
     * @date 2021-05-20 14:26:44
     */
    @PostMapping("add")
    @BusinessLog(title = "業主賬單明細_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public Result add(@RequestBody @Validated(OwnerLeaseBillDetailParam.add.class) OwnerLeaseBillDetailParam ownerLeaseBillDetailParam) {
            ownerLeaseBillDetailService.add(ownerLeaseBillDetailParam);
        return Result.success("新增成功");
    }

    /**
     * 删除業主賬單明細
     *
     * @author anti
     * @date 2021-05-20 14:26:44
     */
    @PostMapping("delete")
    @BusinessLog(title = "業主賬單明細_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public Result delete(@RequestBody @Validated(OwnerLeaseBillDetailParam.delete.class) OwnerLeaseBillDetailParam ownerLeaseBillDetailParam) {
            ownerLeaseBillDetailService.delete(ownerLeaseBillDetailParam);
        return Result.success("删除成功");
    }

    /**
     * 编辑業主賬單明細
     *
     * @author anti
     * @date 2021-05-20 14:26:44
     */
    @PostMapping("edit")
    @BusinessLog(title = "業主賬單明細_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public Result edit(@RequestBody @Validated(OwnerLeaseBillDetailParam.edit.class) OwnerLeaseBillDetailParam ownerLeaseBillDetailParam) {
            ownerLeaseBillDetailService.edit(ownerLeaseBillDetailParam);
        return Result.success("修改成功");
    }

    /**
     * 查看業主賬單明細
     *
     * @author anti
     * @date 2021-05-20 14:26:44
     */
    @GetMapping("detail")
    public Result detail(@Validated(OwnerLeaseBillDetailParam.detail.class) OwnerLeaseBillDetailParam ownerLeaseBillDetailParam) {
        return Result.data(ownerLeaseBillDetailService.detail(ownerLeaseBillDetailParam));
    }

    /**
     * 業主賬單明細列表
     *
     * @author anti
     * @date 2021-05-20 14:26:44
     */
    @GetMapping("list")
    public Result list(OwnerLeaseBillDetailParam ownerLeaseBillDetailParam) {
        return Result.data(ownerLeaseBillDetailService.list(ownerLeaseBillDetailParam));
    }

}
